package com.tianji.learning.controller;

import com.tianji.common.domain.dto.PageDTO;
import com.tianji.learning.domain.dto.AddNoteDto;
import com.tianji.learning.domain.query.NotePageQuery;
import org.springframework.web.bind.annotation.*;
import com.tianji.learning.service.ILearningNoteService;
import com.tianji.learning.domain.po.LearningNote;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.Api;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.RestController;

/**
 * <p>
 *  控制器
 * </p>
 *
 * @author author
 */
@Api(tags = "学习笔记功能接口")
@RestController
@RequiredArgsConstructor
@RequestMapping("/notes")
public class LearningNoteController {

    private final ILearningNoteService learningNoteService;


    @ApiOperation("新增学习笔记")
    @PostMapping
    public void saveLearningNote(@RequestBody AddNoteDto dto) {
        learningNoteService.saveLearningNote(dto);
    }

    @ApiOperation("采集笔记")
    @PostMapping("/gathers/{id}")
    public void gatherNote(@PathVariable("id") Long id) {
        learningNoteService.gatherNote(id);
    }

    @ApiOperation("取消采集")
    @DeleteMapping("/gathers/{id}")
    public void cancelGatherNote(@PathVariable("id") Long id) {
        learningNoteService.cancelGatherNote(id);
    }

    @ApiOperation("用户端分页查询笔记")
    @GetMapping("/page")
    public PageDTO<LearningNote> pageQuery(NotePageQuery query){
        return learningNoteService.pageQuery(query);
    }
}
